
package server.console.groups.setting;


import client.skills.SkillFactory;
import com.alee.extended.list.CheckBoxCellData;
import com.alee.extended.list.CheckBoxListModel;
import com.alee.extended.list.WebCheckBoxList;
import com.alee.extended.panel.CenterPanel;
import com.alee.extended.panel.GroupPanel;
import com.alee.extended.panel.GroupingType;
import com.alee.extended.panel.WebButtonGroup;
import com.alee.laf.button.WebButton;
import com.alee.laf.checkbox.WebCheckBox;
import com.alee.laf.label.WebLabel;
import com.alee.laf.list.WebList;
import com.alee.laf.menu.WebPopupMenu;
import com.alee.laf.panel.WebPanel;
import com.alee.laf.text.WebTextField;
import configs.ServerConfig;
import constants.ServerConstants;
import constants.skills.*;
import provider.MapleOverrideData;

import javax.swing.*;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
import java.awt.*;
import java.lang.reflect.Field;
import java.util.*;
import java.util.List;
import java.util.stream.Collectors;


































 public class JobConfigGroup extends AbstractConfigGroup {
    /*  37 */   public final Class[] classes = new Class[]{战士.class, 英雄.class, 圣骑士.class, 黑骑士.class, 魔法师.class, 火毒.class, 冰雷.class, 主教.class, 弓箭手.class, 神射手.class, 箭神.class, 古迹猎人.class, 飞侠.class, 隐士.class, 侠盗.class, 海盗.class, 冲锋队长.class, 船长.class, 神炮王.class, 龙的传人.class, 初心者.class, 魂骑士.class, 炎术士.class, 风灵使者.class, 夜行者.class, 奇袭者.class, 预备兵.class, 唤灵斗师.class, 豹弩游侠.class, 机械师.class, 爆破手.class, 恶魔猎手.class, 恶魔复仇者.class, 尖兵.class, 战神.class, 龙神.class, 夜光.class, 双弩精灵.class, 双刀.class, 幻影.class, 狂龙战士.class, 虎影.class, 御剑骑士.class, 林之灵.class, 爆莉萌天使.class, 隐月.class, 神之子.class, 米哈尔.class, 剑豪.class, 阴阳师.class, 品克缤.class, 超能力者.class, 影魂异人.class, V矩阵通用.class, 全职业通用.class};

























































    /*  95 */   private final Map<String, Map<Integer, String>> skills = new LinkedHashMap<>();
    /*  96 */   private final List<String> blockSkills = new ArrayList<>(Arrays.asList(ServerConfig.WORLD_BLOCKSKILLS.split(",")));
    /*  97 */   private SkillDataPanel skillDataPanel = new SkillDataPanel();
    /*  98 */   private Map<String, WebTextField> modifiedMaps = new HashMap<>();
    /*  99 */   private int skillid = 0;

















       JobConfigGroup(ConfigPanel owner) {
        /* 117 */
        super(owner, "职业&技能管理");
        for (Class aClass : this.classes) {
            Map<Integer, String> skillss = new LinkedHashMap<>();
            for (Field field : aClass.getDeclaredFields()) {
                try {
                    skillss.put(Integer.valueOf(field.getInt(field.getName())), field.getName());
                }
                 catch (IllegalAccessException e)
                     {
                    e.printStackTrace();
                }

            }

            String jobname = aClass.getName();
            this.skills.put(jobname.split("\\.")[2], skillss);
        }
        /* 122 */
    }

    public Component getPreview() {
        AbstractConfigGroup.TitleWebPanel titleWebPanel1 = new TitleWebPanel("职业&技能设置");

        /* 124 */
        final WebList jobList = new WebList(this.skills.keySet().toArray());
        /* 125 */
        final CheckBoxListModel skillListMode = new CheckBoxListModel();
        /* 126 */
        final WebCheckBoxList skillList = new WebCheckBoxList(skillListMode);
        /* 127 */
        final WebPanel skillData = new WebPanel();
        /* 128 */
        jobList.setSelectionMode(0);
        /* 129 */
        skillList.setSelectionMode(0);

        /* 131 */
        jobList.setPreferredWidth(100);
        /* 132 */
        skillData.setPreferredWidth(300);
        /* 133 */
        skillListMode.addListDataListener(new ListDataListener()
                 {

            public void intervalAdded(ListDataEvent e) {
            }






            public void intervalRemoved(ListDataEvent e) {
            }






            public void contentsChanged(ListDataEvent e) {
                /* 146 */
                String ret = "";
                /* 147 */
                for (CheckBoxCellData checkBoxCellData : skillListMode.getElements()) {
                    /* 148 */
                    int skillid = 0;
                    /* 149 */
                    for (Map.Entry<Integer, String> entry : (Iterable<Map.Entry<Integer, String>>) ((Map) JobConfigGroup.this.skills.get(jobList.getSelectedValue())).entrySet()) {
                        /* 150 */
                        if (((String) entry.getValue()).equals(checkBoxCellData.getUserObject())) {
                            /* 151 */
                            skillid = ((Integer) entry.getKey()).intValue();

                            break;

                        }

                    }
                    /* 155 */
                    if (checkBoxCellData.isSelected() && !JobConfigGroup.this.blockSkills.contains(String.valueOf(skillid))) {
                        /* 156 */
                        JobConfigGroup.this.blockSkills.add(String.valueOf(skillid));
                        continue;
                        /* 157 */
                    }
                    if (!checkBoxCellData.isSelected() && JobConfigGroup.this.blockSkills.contains(String.valueOf(skillid))) {
                        /* 158 */
                        JobConfigGroup.this.blockSkills.remove(String.valueOf(skillid));

                    }

                }

                /* 162 */
                for (String integer : JobConfigGroup.this.blockSkills) {
                    /* 163 */
                    if (!integer.isEmpty()) {
                        /* 164 */
                        ret = ret + integer + ",";

                    }

                }
                /* 167 */
                if (!ret.isEmpty()) {
                    /* 168 */
                    ret = ret.substring(0, ret.length() - 1);

                }

                /* 171 */
                JobConfigGroup.this.owner.getChangeSettingQueue().put("world.blockskills", ret);
                /* 172 */
                if (!JobConfigGroup.this.owner.getWebButtonApply().isEnabled()) {
                    /* 173 */
                    JobConfigGroup.this.owner.getWebButtonApply().setEnabled(true);

                }

            }

        });

        /* 178 */
        skillList.setComponentPopupMenu((JPopupMenu) new WebPopupMenu()
                 {


        });






























        /* 212 */
        skillList.addListSelectionListener(e -> {

            CheckBoxCellData selectedValue = (CheckBoxCellData) ((WebCheckBoxList) e.getSource()).getSelectedValue();


            if (selectedValue != null) {

                this.skillid = getSkillID(selectedValue.getUserObject().toString());


                this.skillDataPanel.removeAll();


                this.skillDataPanel.display(this.skillid);

            }

        });
        /* 223 */
        jobList.addListSelectionListener((e) -> {
            skillListMode.clear();
            ((Map)this.skills.get(jobList.getSelectedValue())).forEach((integer, s) -> {
                skillListMode.addCheckBoxElement(s, this.isBlockSkill(Integer.parseInt(integer+"")));
            });
        });


        /* 229 */
        skillData.add((Component) this.skillDataPanel);
        /* 230 */
        skillData.add((Component) new CenterPanel((Component) new WebButtonGroup(new JComponent[]{(JComponent) new WebButton("应用") {
        }, (JComponent) new WebButton("重置") {
        }})), "South");



































        /* 266 */
        WebPanel panel = new WebPanel()
                 {


        };











        /* 281 */
        return (Component) new GroupPanel(GroupingType.fillLast, 5, false, new Component[]{(Component) titleWebPanel1, (Component) panel});
    }




    public boolean isBlockSkill(int skillid) {
        /* 285 */
        return this.blockSkills.contains(String.valueOf(skillid));

    }



    public Component getOpenJobList() {
        /* 289 */
        WebPanel openJobList = new WebPanel(new GridLayout(5, 5, 0, 5));
        /* 290 */
        for (String s : ServerConstants.JOB_NAMELIST) {
            /* 291 */
            openJobList.add((Component) new WebCheckBox(s, ServerConstants.isOpenJob(s))
                     {


            });

        }








        /* 304 */
        openJobList.setMargin(0, 0, 10, 0);
        /* 305 */
        return (Component) openJobList;

    }



    private void closeJob(String jobname) {
        /* 309 */
        if (!ServerConfig.WORLD_CLOSEJOBS.contains(jobname)) {
            /* 310 */
            ServerConfig.WORLD_CLOSEJOBS += jobname + ",";

        }
        /* 312 */
        saveChange();

    }



    private void openJob(String jobname) {
        /* 316 */
        if (ServerConfig.WORLD_CLOSEJOBS.contains(jobname)) {
            /* 317 */
            ServerConfig.WORLD_CLOSEJOBS = ServerConfig.WORLD_CLOSEJOBS.replace(jobname + ",", "");

        }
        /* 319 */
        saveChange();

    }



    private void saveChange() {
        /* 323 */
        this.owner.getChangeSettingQueue().put("world.closejobs", ServerConfig.WORLD_CLOSEJOBS);
        /* 324 */
        if (!this.owner.getWebButtonApply().isEnabled()) {
            /* 325 */
            this.owner.getWebButtonApply().setEnabled(true);

        }

    }



    private int getSkillID(String name) {
        /* 330 */
        for (Map.Entry<String, Map<Integer, String>> entry : this.skills.entrySet()) {
            /* 331 */
            for (Map.Entry<Integer, String> stringEntry : (Iterable<Map.Entry<Integer, String>>) ((Map) entry.getValue()).entrySet()) {
                /* 332 */
                if (((String) stringEntry.getValue()).equals(name)) {
                    /* 333 */
                    return ((Integer) stringEntry.getKey()).intValue();

                }

            }

        }
        /* 337 */
        return 0;

    }



       public class SkillDataPanel
             extends WebPanel
             {

        private SkillDataPanel() {
        }



        public void display(int skillid) {
            /* 347 */
            String h = SkillFactory.getH(skillid) + " ";
            /* 348 */
            add(new JobConfigGroup.DescLabel(h), "North");
            /* 349 */
            List<String> property = new ArrayList<>();
            /* 350 */
            boolean find = false;
            /* 351 */
            StringBuilder temp = new StringBuilder();
            /* 352 */
            for (char c : h.toCharArray()) {
                /* 353 */
                if (c == '#') {
                    /* 354 */
                    find = true;


                }
                /* 357 */
                else if (find) {
                    /* 358 */
                    if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') && (c < '0' || c > '9')) {
                        /* 359 */
                        find = false;
                        /* 360 */
                        if (temp.length() != 0) {
                            /* 361 */
                            property.add(temp.toString());
                            /* 362 */
                            temp = new StringBuilder();

                        }

                    } else {
                        /* 365 */
                        temp.append(c);

                    }

                }

            }
            /* 369 */
            GroupPanel panel = new GroupPanel(false, new Component[0]);
            /* 370 */
            panel.setMargin(10);
            /* 371 */
            property = (List<String>) property.stream().filter(this::canChange).collect(Collectors.toList());
            /* 372 */
            JobConfigGroup.this.modifiedMaps.clear();
            /* 373 */
            for (String s : property) {
                /* 374 */
                WebLabel label = new WebLabel(s, 4, new Object[0])
                         {


                };


                /* 380 */
                WebTextField field = new WebTextField(getNewValue(skillid, s), 10);
                /* 381 */
                panel.add((Component) new GroupPanel(new Component[]{(Component) label, (Component) field}));
                /* 382 */
                JobConfigGroup.this.modifiedMaps.put(s, field);

            }
            /* 384 */
            add((Component) panel, "Center");
            /* 385 */
            updateUI();

        }



        private String getNewValue(int skillid, String p) {

            String ret;
            /* 390 */
            Map<Integer, Map<String, String>> overridedata = MapleOverrideData.getInstance().getOverridedata();
            /* 391 */
            if (overridedata.containsKey(Integer.valueOf(skillid)) && ((Map) overridedata.get(Integer.valueOf(skillid))).containsKey(p)) {
                /* 392 */
                ret = (String) ((Map) overridedata.get(Integer.valueOf(skillid))).get(p);

            } else {
                /* 394 */
                ret = SkillFactory.getSkillDefaultData(skillid, p);

            }
            /* 396 */
            return (ret == null) ? "" : ret;

        }








        private boolean canChange(String name) {
            /* 405 */
            switch (name) {


                case "c":

                case "dotTime":

                case "dotInterval":

                case "dot":

                case "damage":
                    /* 412 */
                    return false;

            }
            /* 414 */
            return true;

        }

    }


       public class DescLabel extends JTextArea {

        public DescLabel(String text) {
            /* 420 */
            super(text, 2, 10);
            /* 421 */
            setBackground((Color) null);
            /* 422 */
            setEditable(false);
            /* 423 */
            setBorder( null);
            /* 424 */
            setLineWrap(true);
            /* 425 */
            setWrapStyleWord(false);
            /* 426 */
            setFocusable(false);
            /* 427 */
            setMargin(new Insets(5, 5, 5, 15));

        }

    }

}


/* Location:              C:\PGX\Server.jar!\server\console\groups\setting\JobConfigGroup.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */